<?php
use \PFT\Db;
$aid = $_SESSION['sid'];
if (!$aid) {
    exit('Permission Denied!');
}
$fid = intval($_GET['id']);
if (!$fid) {
    exit('Require member id!');
}

$dbConf = include '/var/www/html/new/d/module/common/db.conf.php';
include '/var/www/html/new/d/module/common/Db.class.php';
$sql = "SELECT * FROM pft_wxshops WHERE aid=? AND fid=? LIMIT 1";
Db::Conf($dbConf['remote_1']);
$db_remote = Db::Connect();
$stmt = $db_remote->prepare($sql);
$stmt->execute(array($_SESSION['sid'], $fid));
if ( $shop_info = $stmt->fetch(PDO::FETCH_ASSOC) ) {
    //统计通过该分店关注人数
    $sql_fans   = "SELECT COUNT(*) FROM pft_wxshop_fans WHERE shop_id=?";
    $stmt       = $db_remote->prepare($sql_fans);
    $stmt->execute(array($shop_info['id']));
    $total_fans = $stmt->fetchColumn();
}
else {
//    $sql_info   = "SELECT appid FROM pft_wx WHERE fid=?";
//    Db::Conf($dbConf['localhost']);
//    $stmt = Db::Connect()->prepare($sql_info);
//    $stmt->execute(array($_SESSION['sid']));
}
Db::Close();
?>
<!DOCTYPE html>
<html>
<head>
  <title>微信分店配置</title>
</head>
<body>
<form action="module/wechat/wx_shop_qr.php" method="post">
    <input value="<?=$fid?>" name="fid" type="hidden"/>
    <input value="1" name="show_qr" type="hidden"/>
    <?php if($shop_info):?>
        <div>
            二维码：<br/> <img src="<?=$shop_info['qr_path'] ?>" alt=""/>
        </div>
    <?php else:?>

        还没有创建微信分店，是否现在创建？
        <button type="submit" id="btn-create">创建</button>
    <?endif;?>
</form>
</body>
</html>